# R2 thresholds, p.20 in the Appendix
write.csv(round(sen.out.1$R2tilde.d.thresh, 2), "figures/sensitivity_R2.csv")
# R2s for comparison, p.20 in the Appendix
R2s <- round(c(display(lm(liberal ~ age, data=data))$r.squared,
display(lm(liberal ~ edu_high, data=data))$r.squared,
display(lm(liberal ~ leftright, data=data))$r.squared), 2)
names(R2s) <- c("age", "education", "ideology")
write.csv(R2s, "figures/sensitivity_comparison_R2.csv")
############################################################################
# Check reverse causality
source("code/replication_backlash_reverse_causality.R")
# p. 20
write.csv(cbind(av.ACME.rev,
av.ACME.rev - 1.96*av.ACME.se.rev,
av.ACME.rev + 1.96*av.ACME.se.rev), "figures/ACME_reverse_causality.csv") # reverse ACME
write.csv(cbind(av.ANDE.rev,
av.ANDE.rev - 1.96*av.ANDE.se.rev,
av.ANDE.rev + 1.96*av.ANDE.se.rev), "figures/ANDE_reverse_causality.csv") # reverse ANDE
############################################################################
# Function for Sequential g-Estimation of Moderated ACDE
source("code/replication_backlash_function_ACDE.R")
###########################################################################
# Calculate ACDE for m=5 imputed data sets
source("code/replication_backlash_main_ACDE.R")
# p.25
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_main_results.csv")
###########################################################################
# Population Shares of Supporters and Opponents, p.25
shares <- round(prop.table(table(data$liberal)), 2)
names(shares) <- c("strongly oppose", "oppose", "neither", "support", "strongly support")
write.csv(shares, "figures/population_shares_p_25.csv")
###########################################################################
# Correlations of Authoritarian Items with Support, p.26
source("code/replication_backlash_correlations_authoritarian.R")
write.csv(cor.auth, "figures/correlations_p_26.csv") # Correlations
write.csv(c.alpha, "figures/cronbach_p_26.csv")  # Cronbach's alpha
###########################################################################
# Plot ACDE
# Figure 5
pdf("figures/figure_5.pdf", width=7, height=5)
source("code/replication_backlash_figure_5.R")
dev.off()
#####################################################################################################
# Figure 6
pdf("figures/figure_6.pdf", width=7, height=4)
source("code/replication_backlash_figure_6.R")
dev.off()
#########################################################################
# Subgroup Analysis: Religion and Immigrant Status
#####################################################################################################
# ACME for Muslim Immigrants, p.21
source("code/replication_backlash_muslim_immigrants.R")
write.csv(cbind(av.ACME.mi,
av.ACME.mi - 1.96*av.ACME.se.mi,
av.ACME.mi + 1.96*av.ACME.se.mi), "figures/ACME_muslim_immigrants.csv")
#####################################################################################################
# ACME for Christian Immigrants, p.21
source("code/replication_backlash_christian_immigrants.R")
write.csv(cbind(av.ACME.ci,
av.ACME.ci - 1.96*av.ACME.se.ci,
av.ACME.ci + 1.96*av.ACME.se.ci), "figures/ACME_christian_immigrants.csv")
#####################################################################################################
# ACME for Muslim Natives, p.21
source("code/replication_backlash_muslim_natives.R")
write.csv(cbind(av.ACME.mn,
av.ACME.mn - 1.96*av.ACME.se.mn,
av.ACME.mn + 1.96*av.ACME.se.mn), "figures/ACME_muslim_natives.csv")
#####################################################################################################
# ACME for Christian Natives, p.21
source("code/replication_backlash_christian_natives.R")
write.csv(cbind(av.ACME.cn,
av.ACME.cn - 1.96*av.ACME.se.cn,
av.ACME.cn + 1.96*av.ACME.se.cn), "figures/ACME_christian_natives.csv")
###########################################################################
# Plot
# Figure 3
pdf("figures/figure_3.pdf")
source("code/replication_backlash_figure_3.R")
dev.off()
#########################################################################
# Function for ACDE for Subgroup Analysis
source("code/replication_backlash_function_ACDE_subgroup.R")
###########################################################################
# ACDE for Muslim Immigrants, p.28
source("code/replication_backlash_ACDE_muslim_immigrants.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_muslim_immigrants.csv")
###########################################################################
# Figure 7A
pdf("figures/figure_7A.pdf", width=7, height=5)
source("code/replication_backlash_figure_7A.R")
dev.off()
###########################################################################
# ACDE for Christian Immigrants, p.28
source("code/replication_backlash_ACDE_christian_immigrants.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_christian_immigrants.csv")
###########################################################################
# Figure 7B
pdf("figures/figure_7B.pdf", width=7, height=5)
source("code/replication_backlash_figure_7B.R")
dev.off()
###########################################################################
# ACDE for Muslim Natives
source("code/replication_backlash_ACDE_muslim_natives.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_muslim_natives.csv")
###########################################################################
# Figure  7C
pdf("figures/figure_7C.pdf", width=7, height=5)
source("code/replication_backlash_figure_7C.R")
dev.off()
###########################################################################
# ACDE for Christian Natives
source("code/replication_backlash_ACDE_christian_natives.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_christian_natives.csv")
###########################################################################
# Figure  7D
pdf("figures/figure_7D.pdf", width=7, height=5)
source("code/replication_backlash_figure_7D.R")
dev.off()
#########################################################################
# Subgroup Analysis 2: Religion and Religiosity
#########################################################################
# ACME for Secular Muslims, p.23
source("code/replication_backlash_secular_muslims.R")
write.csv(cbind(av.ACME.ms,
av.ACME.ms - 1.96*av.ACME.se.ms,
av.ACME.ms + 1.96*av.ACME.se.ms), "figures/ACME_secular_muslims.csv")
#########################################################################
# ACME for Devout Muslims, p.23
source("code/replication_backlash_devout_muslims.R")
write.csv(cbind(av.ACME.md,
av.ACME.md - 1.96*av.ACME.se.md,
av.ACME.md + 1.96*av.ACME.se.md), "figures/ACME_devout_muslims.csv")
#########################################################################
# ACME for Radical Muslims
source("code/replication_backlash_radical_muslims.R")
write.csv(cbind(av.ACME.mr,
av.ACME.mr - 1.96*av.ACME.se.mr,
av.ACME.mr + 1.96*av.ACME.se.mr), "figures/ACME_radical_muslims.csv")
###########################################################################
# Figure 4A
pdf("figures/figure_4A.pdf")
source("code/replication_backlash_figure_4A.R")
dev.off()
##########################################################################
# ACME for Secular Christians, p.23
source("code/replication_backlash_secular_christians.R")
write.csv(cbind(av.ACME.cs,
av.ACME.cs - 1.96*av.ACME.se.cs,
av.ACME.cs + 1.96*av.ACME.se.cs), "figures/ACME_secular_christians.csv")
##########################################################################
# ACME for Devout Christians, p.23
source("code/replication_backlash_devout_christians.R")
write.csv(cbind(av.ACME.cd,
av.ACME.cd - 1.96*av.ACME.se.cd,
av.ACME.cd + 1.96*av.ACME.se.cd), "figures/ACME_devout_christians.csv")
#########################################################################
# ACME for Radical Christians, p.23
source("code/replication_backlash_radical_christians.R")
write.csv(cbind(av.ACME.cr,
av.ACME.cr - 1.96*av.ACME.se.cr,
av.ACME.cr + 1.96*av.ACME.se.cr), "figures/ACME_radical_christians.csv")
############################################################################
# Figure 4B
pdf("figures/figure_4B.pdf")
source("code/replication_backlash_figure_4B.R")
dev.off()
############################################################################
# Function for ACDE for Subgroup Analysis 2
source("code/replication_backlash_function_ACDE_subgroup_2.R")
###########################################################################
# ACDE Radical Muslims
source("code/replication_backlash_ACDE_radical_muslims.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_radical_muslims.csv")
##########################################################################
# Figure 8A
pdf("figures/figure_8A.pdf", width=7, height=5)
source("code/replication_backlash_figure_8A.R")
dev.off()
###########################################################################
# ACDE for Devout Muslims, p.28
source("replication_backlash_ACDE_devout_muslims.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_devout_muslims.csv")
###########################################################################
# Figure 8C
pdf("figures/figure_8C.pdf", width=7, height=5)
source("code/replication_backlash_figure_8C.R")
dev.off()
###########################################################################
# ACDE for Secular Muslims
source("code/replication_backlash_ACDE_secular_muslims.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_secular_muslims.csv")
###########################################################################
# Figure 8E
pdf("figures/figure_8E.pdf", width=7, height=5)
source("code/replication_backlash_figure_8E.R")
dev.off()
###########################################################################
# ACDE for Radical Christians, p.28
source("code/replication_backlash_ACDE_radical_christians.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_radical_christians.csv")
###########################################################################
# Figure 8B
pdf("figures/figure_8B.pdf", width=7, height=5)
source("code/replication_backlash_figure_8B.R")
dev.off()
###########################################################################
# ACDE for Devout Christians
source("code/replication_backlash_ACDE_devout_christians.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_devout_christians.csv")
###########################################################################
# Figure 8D
pdf("figures/figure_8D.pdf", width=7, height=5)
source("code/replication_backlash_figure_8D.R")
dev.off()
###########################################################################
# ACDE for Secular Christians
source("code/replication_backlash_ACDE_devout_christians.R")
write.csv(round(cbind(combined.res[,1],
combined.res[,1] -  1.96*combined.res[,2],
combined.res[,1] + 1.96*combined.res[,2]),2), "figures/ACDE_secular_christians.csv")
###########################################################################
# Figure 8F
pdf("figures/figure_8F.pdf", width=7, height=5)
source("code/replication_backlash_figure_8F.R")
dev.off()
############################################################################
# Additional Analyses in Appendix
############################################################################
# Multiple Imputation for Additional Analyses
source("code/replication_backlash_imputations_additional_analyses.R")
################################################################################
# Function to Calculate ACME
source("code/replication_backlash_function_ACME.R")
################################################################################
# Function to Calculate ANDE
source("code/replication_backlash_function_ANDE.R")
############################################################################
# Further Consequences for Social and Political Rights
# Table S6 in Appendix
source("code/replication_backlash_welfare.R")
source("code/replication_backlash_vote.R")
source("code/replication_backlash_office.R")
write.csv(combined.res.des, "figures/table_S6_welfare.csv") # Deserve Welfare Equation
write.csv(combined.res.vote, "figures/table_S6_vote.csv") # Right to Vote Equation
write.csv(combined.res.off, "figures/table_S6_office.csv") # Hold Public Office Equation
# p.24 in Appendix
write.csv(cbind(av.ACME.des,
av.ACME.des - 1.96*av.ACME.se.des,
av.ACME.des + 1.96*av.ACME.se.des), "figures/ACME_welfare.csv")  # ACME Deserve Welfare
write.csv(cbind(av.ACME.vot,
av.ACME.vot - 1.96*av.ACME.se.vot,
av.ACME.vot + 1.96*av.ACME.se.vot), "figures/ACME_vote.csv") # ACME Right to Vote
write.table(cbind(av.ACME.off ,
av.ACME.off  - 1.96*av.ACME.se.off ,
av.ACME.off  + 1.96*av.ACME.se.off ), "figures/ACME_office.csv") # ACME Hold Public Office
write.csv(cbind(av.ANDE.des,
av.ANDE.des - 1.96*av.ANDE.se.des,
av.ANDE.des + 1.96*av.ANDE.se.des), "figures/ANDE_welfare.csv")  # ANDE Deserve Welfare
write.csv(cbind(av.ANDE.vot,
av.ANDE.vot - 1.96*av.ANDE.se.vot,
av.ANDE.vot + 1.96*av.ANDE.se.vot), "figures/ANDE_vote.csv") # ANDE Right to Vote
write.csv(cbind(av.ANDE.off ,
av.ANDE.off  - 1.96*av.ANDE.se.off ,
av.ANDE.off  + 1.96*av.ANDE.se.off ), "figures/ANDE_office.csv") # ANDE Hold Public Office
############################################################################
# Plot ACMEs and ANDEs for Further Analyses
# Figure S5 in Appendix
pdf("figures/figure_S5.pdf", width=5, height=7)
source("code/replication_backlash_figure_S5.R")
dev.off()
############################################################################
# Plot ACDE for Further Analyses
# Figure S6 in Appendix
source("code/replication_backlash_ACDE_further_analyses.R")
# p.26 in Appendix
write.csv(round(cbind(combined.res.des[,1],
combined.res.des[,1] -  1.96*combined.res.des[,2],
combined.res.des[,1] + 1.96*combined.res.des[,2]),2), "figures/ACDE_welfare.csv") # ACDE Deserve Welfare
write.csv(round(cbind(combined.res.vote[,1],
combined.res.vote[,1] -  1.96*combined.res.vote[,2],
combined.res.vote[,1] + 1.96*combined.res.vote[,2]),2), "figures/ACDE_vote.csv") # ACDE Right to Vote
write.csv(round(cbind(combined.res.off[,1],
combined.res.off[,1] -  1.96*combined.res.off[,2],
combined.res.off[,1] + 1.96*combined.res.off[,2]),2), "figures/ACDE_office.csv") # ACDE Hold Public Office
pdf("figures/figure_S6.pdf", width=5, height=7)
source("code/replication_backlash_figure_S6.R")
dev.off()
############################################################################
End <- Sys.time()
Start-End
# END
setwd("~/Dropox/UK Experiment/PSRM/Replication_Backlash_PSRM")
setwd("~/Dropbox/UK Experiment/PSRM/Replication_Backlash_PSRM")
data <- read.dta("data/replication_backlash_data.dta", convert.factors=F)
####################################################################################
# Prepare and Check Data
#####################################################################################
# Describing the sample, p.13
# N
write.csv(dim(data)[1], "figures/describe_sample_N.csv")
# Females
write.csv(round(mean(data$E730==2)*100), "figures/describe_sample_females.csv")
# Age
age <- round(c(mean(data$E731), sd(data$E731), min(data$E731), max(data$E731)), 1)
names(age) <- c("mean", "sd", "min", "max")
write.csv(age, "figures/describe_sample_age.csv")
# University degree
write.csv(round(mean(data$edu_high, na.rm=T)*100), "figures/describe_sample_university.csv")
# White British
write.csv(round(mean(data$ethn_brit, na.rm=T)*100), "figures/describe_sample_university.csv")
#####################################################################################
# Recode Variables
source("code/replication_backlash_recode.R")
#####################################################################################
# Check Balance
# Table S1 in Appendix
source("code/replication_backlash_balance_check.R")
write.csv(balance.tab, "figures/table_S1.csv")
#####################################################################################
# Mean Comparisons
# Table S2 & S3 in Appendix
source("code/replication_backlash_mean_comparisons.R")
write.csv(support.tab, "figures/table_S2.csv")
write.csv(feel.tab, "figures/table_S3.csv")
#####################################################################################
# Check Symmetry of Bans and Permits
# Table S4 in Appendix
source("code/replication_backlash_check_symmetry.R")
write.csv(cbind(ban, perm), "figures/table_S4.csv")
# p-value in footnote 6, p.17 (and p.11 of the Appendix)
write.csv(round(p.chi$p.value, 2), "figures/p_footnote_6.csv")
#####################################################################################
# Main Results
#####################################################################################
# Multiple Imputation of m=5 Datasets
source("code/replication_backlash_imputations.R")
#####################################################################################
# Models for Main Results
source("code/replication_backlash_main_models.R")
write.csv(m.combined.res, "figures/table_S5_mediator_equation.csv") # Mediator Equation
write.csv(y.combined.res, "figures/table_S5_outcome_equation.csv") # Outcome Equation
################################################################################
# Function to Calculate ACME
source("code/replication_backlash_function_ACME.R")
#############################################################################
# Calculate ACME for m=5 multiply imputed data sets
source("code/replication_backlash_main_ACME.R")
# p.20
write.csv(cbind(av.ACME,
av.ACME - 1.96*av.ACME.se,
av.ACME + 1.96*av.ACME.se), "figures/ACME_main_results.csv") # Average ACME
# footnote 9, p.19
write.csv(cbind(res.ACME,
res.ACME - 1.96*res.ACME.se,
res.ACME + 1.96*res.ACME.se), "figures/ACME_main_results_res_footnote_9.csv") # ACME for Restrictive Policy
write.csv(cbind(lib.ACME,
lib.ACME - 1.96*lib.ACME.se,
lib.ACME + 1.96*lib.ACME.se), "figures/ACME_main_results_lib_footnote_9.csv") # ACME for Liberal Policy
################################################################################
# Function to Calculate ANDE
source("code/replication_backlash_function_ANDE.R")
#############################################################################
# Calculate ANDE for m=5 multiply imputed data sets
source("code/replication_backlash_main_ANDE.R")
# footnote 9, p.19
write.csv(cbind(av.ANDE,
av.ANDE - 1.96*av.ANDE.se,
av.ANDE + 1.96*av.ANDE.se), "figures/ANDE_main_results.csv") # Average ANDE
write.csv(cbind(res.ANDE,
res.ANDE - 1.96*res.ANDE.se,
res.ANDE + 1.96*res.ANDE.se), "figures/ANDE_main_results_res_footnote_9.csv") # ANDE for Restrictive Policy
write.csv(cbind(res.ANDE,
res.ANDE - 1.96*res.ANDE.se,
res.ANDE + 1.96*res.ANDE.se), "figures/ANDE_main_results_lib_footnote_9.csv") # ANDE for Liberal Policy
##########################################################################
# Plot Figure 2
pdf("figures/figure_2.pdf", width=7, height=5)
source("code/replication_backlash_figure_2.R")
dev.off()
############################################################################
# Sensitivity Analysis
# Figures S3 and S4 in the Appendix
source("code/replication_backlash_sensitivity_analysis.R")
# Rho thresholds, p.18 in the Appendix
write.csv(sen.out.1$err.cr.d, "figures/sensitivity_rho.csv")
# R2 thresholds, p.20 in the Appendix
write.csv(round(sen.out.1$R2tilde.d.thresh, 2), "figures/sensitivity_R2.csv")
# R2s for comparison, p.20 in the Appendix
R2s <- round(c(display(lm(liberal ~ age, data=data))$r.squared,
display(lm(liberal ~ edu_high, data=data))$r.squared,
display(lm(liberal ~ leftright, data=data))$r.squared), 2)
names(R2s) <- c("age", "education", "ideology")
write.csv(R2s, "figures/sensitivity_comparison_R2.csv")
############################################################################
# Check reverse causality
source("code/replication_backlash_reverse_causality.R")
# p. 20
write.csv(cbind(av.ACME.rev,
av.ACME.rev - 1.96*av.ACME.se.rev,
av.ACME.rev + 1.96*av.ACME.se.rev), "figures/ACME_reverse_causality.csv") # reverse ACME
write.csv(cbind(av.ANDE.rev,
av.ANDE.rev - 1.96*av.ANDE.se.rev,
av.ANDE.rev + 1.96*av.ANDE.se.rev), "figures/ANDE_reverse_causality.csv") # reverse ANDE
############################################################################
# Function for Sequential g-Estimation of Moderated ACDE
source("code/replication_backlash_function_ACDE.R")
###########################################################################
# Calculate ACDE for m=5 imputed data sets
source("code/replication_backlash_main_ACDE.R")
data <- read.dta("data/replication_backlash_data.dta", convert.factors=F)
# N
write.csv(dim(data)[1], "figures/describe_sample_N.csv")
write.csv(round(mean(data$E730==2)*100), "figures/describe_sample_females.csv")
# Age
age <- round(c(mean(data$E731), sd(data$E731), min(data$E731), max(data$E731)), 1)
names(age) <- c("mean", "sd", "min", "max")
write.csv(age, "figures/describe_sample_age.csv")
# University degree
write.csv(round(mean(data$edu_high, na.rm=T)*100), "figures/describe_sample_university.csv")
# White British
write.csv(round(mean(data$ethn_brit, na.rm=T)*100), "figures/describe_sample_university.csv")
#####################################################################################
# Recode Variables
source("code/replication_backlash_recode.R")
source("code/replication_backlash_balance_check.R")
write.csv(balance.tab, "figures/table_S1.csv")
#####################################################################################
# Mean Comparisons
# Table S2 & S3 in Appendix
source("code/replication_backlash_mean_comparisons.R")
write.csv(support.tab, "figures/table_S2.csv")
write.csv(feel.tab, "figures/table_S3.csv")
#####################################################################################
# Check Symmetry of Bans and Permits
# Table S4 in Appendix
source("code/replication_backlash_check_symmetry.R")
write.csv(cbind(ban, perm), "figures/table_S4.csv")
# p-value in footnote 6, p.17 (and p.11 of the Appendix)
write.csv(round(p.chi$p.value, 2), "figures/p_footnote_6.csv")
#####################################################################################
# Multiple Imputation of m=5 Datasets
source("code/replication_backlash_imputations.R")
#####################################################################################
# Models for Main Results
source("code/replication_backlash_main_models.R")
library(foreign)
library(arm)
library(mice)
library(mediation)
library(ltm)
library(foreign)
library(mice)
library(mediation)
library(ltm)
library(arm)
#####################################################################################
# Models for Main Results
source("code/replication_backlash_main_models.R")
m.comp.1 <- lm(liberal ~ rel_banperm + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.1)
y.comp.1 <- lm(rel_feel ~ rel_banperm*liberal + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.1)
m.comp.2 <- lm(liberal ~ rel_banperm + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.2)
y.comp.2 <- lm(rel_feel ~ rel_banperm*liberal + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.2)
m.comp.3 <- lm(liberal ~ rel_banperm + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.3)
y.comp.3 <- lm(rel_feel ~ rel_banperm*liberal + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.3)
m.comp.4 <- lm(liberal ~ rel_banperm + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.4)
y.comp.4 <- lm(rel_feel ~ rel_banperm*liberal + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.4)
m.comp.5 <- lm(liberal ~ rel_banperm + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.5)
y.comp.5 <- lm(rel_feel ~ rel_banperm*liberal + fem + I(age/10) + edu_high + religiosity + leftright + rel_muslim + rel_dev + rel_rad + rel_immigrant, data=imp.data.5)
c.1 <- coef(m.comp.1)
c.2 <- coef(m.comp.2)
c.3 <- coef(m.comp.3)
c.4 <- coef(m.comp.4)
c.5 <- coef(m.comp.5)
s.1 <- se.coef(m.comp.1)
s.2 <- se.coef(m.comp.2)
s.3 <- se.coef(m.comp.3)
s.4 <- se.coef(m.comp.4)
s.5 <- se.coef(m.comp.5)
coefs <- cbind(c.1, c.2, c.3, c.4, c.5)
c.combined <- apply(coefs, 1, mean)
var.within <- cbind(s.1^2, s.2^2, s.3^2, s.4^2, s.5^2)
var.within <- apply(var.within, 1, mean)
m <- 5
var.between <- (coefs - c.combined)^2
var.between <-  apply(var.between, 1, sum)
var.between <-  (m-1)^-1 * var.between
s.combined <- sqrt(var.within + (1 + m^-1) * var.between )
combined.res <- cbind(c.combined, s.combined)
m.combined.res <- round(combined.res, 2)
m.combined.res <- rbind(m.combined.res, display(m.comp.1)$n, display(m.comp.1)$r.squared)
?display
dev.off()
